package ui
{
	import arens.EnumArens;
	
	import feathers.controls.Button;
	import feathers.controls.ScrollContainer;
	import feathers.core.FeathersControl;
	import feathers.layout.HorizontalLayout;
	import feathers.layout.VerticalLayout;
	
	import flash.media.Sound;
	
	import managers.LoaderArens;
	import managers.SoundManager;
	
	import starling.core.Starling;
	import starling.events.Event;
	
	public class BottomGameMenu extends FeathersControl
	{
		private var container:ScrollContainer;
		public function BottomGameMenu()
		{
			super();
		}
		
		override protected function draw():void
		{
			// TODO Auto Generated method stub
			super.draw();
			container.validate();
			this.x = ((stage.stageWidth - container.width)/2+40)>>1;
			this.y = ((stage.stageHeight - container.height)/2 +440)>>1;
		}
		
		override protected function initialize():void
		{
			// TODO Auto Generated method stub
			super.initialize();
			var btnMainMenu:Button = new Button();
			btnMainMenu.nameList.add("test");
			btnMainMenu.label = "Main menu";
			btnMainMenu.addEventListener(Event.TRIGGERED, onBtnMainMenu);
			
			var hLayer:HorizontalLayout = new HorizontalLayout();
			hLayer.paddingTop = 20;
			hLayer.paddingBottom = 0;
			hLayer.paddingRight = 20;
			hLayer.paddingLeft = 20;
			hLayer.gap = 2;
			hLayer.horizontalAlign = HorizontalLayout.HORIZONTAL_ALIGN_CENTER;
			hLayer.verticalAlign = VerticalLayout.HORIZONTAL_ALIGN_CENTER;
			
			container = new ScrollContainer();
			container.layout = hLayer;
			container.addChild(btnMainMenu);
			addChild(container);
		}
		
		private function onBtnMainMenu(e:Event):void{
			SoundManager.getInstance().playSound(SoundManager.BUTTON_CLICK);
			var rClass:RootClass = RootClass.instance;
			rClass.loaderArena = new LoaderArens(EnumArens.MAIN_SCREEN,rClass.arenaLayer);
		}
		
	}
}